#include "IIC_HAL_QG.h"

void vfnIIC_SetAddress(uint8 u8address) 
{
    IICA = u8address;  
}

void vfnIIC_BaudRate(uint8 u8rate)
{
    IICF = u8rate;  
}

void vfnIIC_ModuleStatus(uint8 u8status)
{
    IICC_IICEN = u8status;
}

void vfnIIC_InterruptStatus(uint8 u8status)
{
    IICC_IICIE = u8status;
}
 
void vfnIIC_ModeSelect(uint8 u8mode)
{
    IICC_MST = u8mode;
}

void vfnIIC_Restart(void)
{
    IICC_RSTA = 1;
}

void vfnIIC_TxAcknowledgeStatus(uint8 u8status)
{
    IICC_TXAK = u8status;
}

void vfnIIC_DataDirection(uint8 u8mode)
{
    IICC_TX = u8mode;
}

uint8 u8IIC_TransferComplete(void)
{
    return IICS_TCF;
}

uint8 u8IIC_CheckIfAdressed(void)
{
    return IICS_IAAS;
}

uint8 u8IIC_BusBusy(void)
{
    return IICS_BUSY;
}

uint8 u8IIC_CheckArbitrationLost(void)
{
    return IICS_ARBL;
}

uint8 u8IIC_SlaveStatus(void)
{
    return IICS_SRW;
}

uint8 u8IIC_CheckInterrupt(void)
{
    return IICS_IICIF; 
}

uint8 u8IIC_AckReceived(void)
{
    return IICS_RXAK;
}

void vfnIIC_SendData(uint8 u8data)
{

    IICD = u8data;
}

uint8 u8IIC_ReadData(void)
{
    return IICD;
}

void vfnIIC_ClearInterruptFlag(void)
{
    IICS_IICIF = 1;
}

uint8 u8IIC_MasterMode(void)  
{
    return IICC_MST;
}
uint8 u8IIC_TransmitMode(void)
{
    return IICC_TX;
}
uint8 u8IIC_ArbitrationLost(void)
{
    return IICS_ARBL;
}

void vfnIIC_ClearArbitrationLost(void)
{
    IICS_ARBL = 1;
}
